﻿#pragma once

namespace Util
{
  // from: https://stackoverflow.com/a/57595105
  template <typename T, typename... Rest>
  void HashCombine(std::size_t &seed, const T &v, const Rest &...rest)
  {
    seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
    (HashCombine(seed, rest), ...);
  };

  class HashIVec2
  {
  public:
    std::size_t operator()(const glm::ivec2 &v) const
    {
      std::size_t seed = 0;
      HashCombine(seed, v.x, v.y);
      return seed;
    }
  };

  class HashIVec3
  {
  public:
    std::size_t operator()(const glm::ivec3 &v) const
    {
      std::size_t seed = 0;
      HashCombine(seed, v.x, v.y, v.z);
      return seed;
    }
  };
} // namespace Util